<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Photos: <%= controller.action_name %></title>
  <%= javascript_include_tag 'swfupload' %>
  <%= javascript_include_tag 'handlers' %>
  <%= stylesheet_link_tag 'scaffold' %>
  <%= stylesheet_link_tag 'swfupload' %>
</head>
<body>

<p style="color: green"><%= flash[:notice] %></p>

<h1>New photo</h1>

<p><%= link_to 'Return to index', test_field_photos_url %></p>

<p>This section is the traditional upload form. Normally it would be hidden in favor of the swfupload button below.</p>

<%= error_messages_for :photo %>

<% form_for @photo, :url => test_field_photos_url, :html => { :multipart => true } do |f| %>
  <p><%= f.file_field :uploaded_data %></p>
  <%= submit_tag 'Upload image' %> or <%= link_to 'Cancel', test_field_photos_url %>
<% end %>

<br />
<hr />

<p>SWFUpload button allows uploading more than one image at a time. This section adapted from index.php in the swfupload application demo. In a final application the Graceful Degradation plugin would show or hide the traditional or swfupload divisions based on whether the swfupload program successfully initialized.</p>

<script type="text/javascript">
		var swfu;
		window.onload = function () {
			swfu = new SWFUpload({
				// Backend Settings
				upload_url: "<%= test_field_photos_url %>",
				post_params: {
          '<%= ActionController::Base.session_options[:key] %>': '<%= cookies[ActionController::Base.session_options[:key]] %>',
          '<%= request_forgery_protection_token %>': '<%= form_authenticity_token %>'
        },


				// File Upload Settings
				file_size_limit : "10 MB",	// 2MB
				file_types : "*.jpg",
				file_types_description : "JPG Images",
				file_upload_limit : "0",

				// Event Handler Settings - these functions as defined in Handlers.js
				//  The handlers are not part of SWFUpload but are part of my website and control how
				//  my website reacts to the SWFUpload events.
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,

				// Button Settings
				button_image_url : "images/SmallSpyGlassWithTransperancy_17x18.png",
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 180,
				button_height: 18,
				button_text : '<span class="button">Select Images <span class="buttonSmall">(2 MB Max)</span></span>',
				button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
				button_text_top_padding: 0,
				button_text_left_padding: 18,
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				button_cursor: SWFUpload.CURSOR.HAND,

				// Flash Settings
				flash_url : "/assets/swfupload.swf",

				custom_settings : {
					upload_target : "divFileProgressContainer"
				},

				// Debug Settings
				debug: true
			});
		};
	</script>

<div style="margin: 0px 10px;">
	<form>
		<div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
			<span id="spanButtonPlaceholder"></span>

		</div>
	</form>
		<div id="divFileProgressContainer" style="height: 75px;"></div>
	<div id="thumbnails"></div>
</div>
</body>
</html>